package com.webdev.newtech.controller;

import com.webdev.newtech.domain.TlCat;
import com.webdev.newtech.domain.TlNotice;
import com.webdev.newtech.domain.TlProduct;
import com.webdev.newtech.domain.TlService;
import com.webdev.newtech.service.ITlCatService;
import com.webdev.newtech.service.ITlNoticeService;
import com.webdev.newtech.service.ITlProductService;
import com.webdev.newtech.service.ITlServiceService;
import com.webdev.newtech.utils.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("prev")
public class PrevController {
    @Resource
    ITlCatService catService;
    @GetMapping("catlist")
    public AjaxResult catList(){
        TlCat cat=new TlCat();
        cat.setStatus(1);
        return AjaxResult.success(catService.getList(cat));
    }
    @Resource
    ITlProductService productService;
    @GetMapping("productlist")
    public AjaxResult productList(){
        TlProduct product=new TlProduct();
        product.setStatus(1);
        return AjaxResult.success(productService.getList(product));
    }

    @GetMapping("getProductDetail")
    public AjaxResult getProductDetail(Integer id){
        return AjaxResult.success(productService.getById(id));
    }
    @GetMapping("getCatDetail")
    public AjaxResult getCatDetail(Integer id){
        return AjaxResult.success(catService.getById(id));
    }


    @Resource
    ITlServiceService serviceService;
    @GetMapping("servicelist")
    public AjaxResult serviceList(){
        TlService service=new TlService();
        service.setStatus(1);

        return AjaxResult.success(serviceService.getList(service));
    }
    @GetMapping("getServiceDetail")
    public AjaxResult getServiceDetail(Integer id){
        return AjaxResult.success(serviceService.getById(id));
    }

    @Resource
    ITlNoticeService noticeService;

    @GetMapping("noticelist")
    public AjaxResult noticeList(){
        TlNotice notice=new TlNotice();
        notice.setStatus(1);

        return AjaxResult.success(noticeService.getList(notice));
    }
    @GetMapping("getNoticeDetail/{id}")
    public AjaxResult  getNoticeDetail(@PathVariable Integer id){
        return AjaxResult.success(noticeService.getById(id));
    }



}
